import Vue from "vue";

import VueRouter from "vue-router";
import { userRouterMap } from "./user_router";
import { companyRouterMap } from "./company_router";
import { studentRouterMap } from "./student_router";

import local from "../store/local";

Vue.use(VueRouter);

const constantRouterMap = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/Login"),
  },
];

// let arr = [...constantRouterMap];
// if (local.getUserInfo()) {
//   if (local.getUserInfo().type == 0) {
//     arr = [...constantRouterMap, ...userRouterMap];
//   } else if (local.getUserInfo().type == 1) {
//     arr = [...constantRouterMap, ...companyRouterMap];
//   }
// }

const router = new VueRouter({
  routes: [
    ...constantRouterMap,
    ...userRouterMap,
    ...companyRouterMap,
    ...studentRouterMap,
  ],
  // routes: arr,
});

export default router;
